package ms.maplestory.boot.service.jobs.adventurer;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import ms.maplestory.boot.client.character.Char;
import ms.maplestory.boot.client.character.CharStat;
import ms.maplestory.boot.enums.JobType;
import ms.maplestory.boot.service.jobs.Job;
import ms.maplestory.boot.service.jobs.JobService;
import org.springframework.stereotype.Service;

@Slf4j
@Job(JobType.Beginner)
@Service
@RequiredArgsConstructor
public class BeginnerService extends JobService {

    public static final int RECOVERY = 1001; // 团队治疗
    public static final int NIMBLE_FEET = 1002; // 疾风步
    public static final int THREE_SNAILS = 1000; // 蜗牛投掷术

    private int[] addedSkills = new int[]{
            RECOVERY,
            NIMBLE_FEET,
            THREE_SNAILS
    };

    @Override
    public void init(Char chr) {
        super.init(chr);
        if (chr.getId() != 0 && isHandlerOfJob(chr.getStat().getJob())) {
            for (int id : addedSkills) {
//                if (!chr.hasSkill(id)) {
//                    Skill skill = SkillData.getSkillDeepCopyById(id);
//                    skill.setMasterLevel(3);
//                    skill.setMaxLevel(3);
//                    skill.setChr(chr);
//                    skillRepository.save(skill);
//                    chr.getSkills().add(skill);
//                }
            }
        }
    }

    @Override
    public void initCharCreationStats(Char chr) {
        super.initCharCreationStats(chr);
        CharStat cs = chr.getStat();
        cs.setPosMap(0);
        charStatRepository.save(cs);
    }

    @Override
    public boolean isHandlerOfJob(int id) {
        return id == JobType.Beginner.getId();
    }

}
